<?php
/**
 * Desc:
 * User: hollowcg@foxmail.com
 * Date: 2019/5/27
 */

namespace app\admin\controller;


use think\Request;

class SiteOption extends Common
{
    public function index(){
        $data = getSiteOption();
        $this->assign('data',$data);
        return view();
    }

    public function save(){
        $data = input();
        $file = APP_PATH .'/extra/site_option.php';
        $config = config('site_option');
        $configer = array_merge($config,array_change_key_case($data,CASE_UPPER));
        $str = "<?php\r\n /** \r\n * Desc:网站基础信息\r\n * User: hollowcg\r\n * Contact: QQ:3511691138\r\n */ return ".var_export($configer,true).";?>";
        if(file_put_contents($file,$str)) {
            return apiResult();
        }else{
            return apiResult([],1,'操作失败');
        }

    }
}